]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
FdoNotificationDaemon: Emit ActivationToken before ActionInvoked signal
authorJulian Sparber <julian@sparber.net>
Mon, 19 Feb 2024 16:31:52 +0000 (17:31 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 28 Feb 2024 13:51:18 +0000 (13:51 +0000)
Two years ago FDO notifications spec gained the ability to pass an
activation token (often called startup id) let's finally implement it.

See: https://gitlab.freedesktop.org/xdg/xdg-specs/-/commit/b9a470004d

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/358
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3199>

data/dbus-interfaces/org.freedesktop.Notifications.xml
js/dbusServices/notifications/notificationDaemon.js
js/ui/notificationDaemon.js

index 0ed8657432093c92bd5dd4d8fef0e5f27a98b0c3..dde758500050ec34891cb7373ccbdec11c117bd3 100644 (file)
@@ -31,5 +31,9 @@
       <arg type="u"/>
       <arg type="s"/>
     </signal>
+    <signal name="ActivationToken">
+      <arg type="u"/>
+      <arg type="s"/>
+    </signal>
   </interface>
 </node>
index 38ad9118f259ed86002486d420861aa6a9b7146b..0be91cef910cded7280843923c9596b82e495113 100644 (file)
@@ -27,6 +27,14 @@ export const NotificationDaemon = class extends ServiceImplementation {
                     log(error.message);
             });
 
+        this._proxy.connectSignal('ActivationToken',
+            (proxy, sender, params) => {
+                const [id] = params;
+                this._emitSignal(
+                    this._activeNotifications.get(id),
+                    'ActivationToken',
+                    new GLib.Variant('(us)', params));
+            });
         this._proxy.connectSignal('ActionInvoked',
             (proxy, sender, params) => {
                 const [id] = params;
index 4aceb2468504822748978befbc194d7cbe1b9bd9..09c1c6b184384a2c711c6544062aa9d2be783914 100644 (file)
@@ -217,6 +217,7 @@ class FdoNotificationDaemon {
                     hasDefaultAction = true;
                 } else {
                     notification.addAction(label, () => {
+                        this._emitActivationToken(source, ndata.id);
                         this._emitActionInvoked(ndata.id, actionId);
                     });
                 }
@@ -225,6 +226,7 @@ class FdoNotificationDaemon {
 
         if (hasDefaultAction) {
             notification.connect('activated', () => {
+                this._emitActivationToken(source, ndata.id);
                 this._emitActionInvoked(ndata.id, 'default');
             });
         } else {
@@ -301,6 +303,16 @@ class FdoNotificationDaemon {
         this._dbusImpl.emit_signal('ActionInvoked',
             GLib.Variant.new('(us)', [id, action]));
     }
+
+    _emitActivationToken(source, id) {
+        const context = global.create_app_launch_context(0, -1);
+        const info = source.app?.get_app_info();
+        if (info) {
+            const token = context.get_startup_notify_id(info, []);
+            this._dbusImpl.emit_signal('ActivationToken',
+                GLib.Variant.new('(us)', [id, token]));
+        }
+    }
 }
 
 export const FdoNotificationDaemonSource = GObject.registerClass(